<template>
  <div class="section-wrap" style="height:100%;padding-top: 40px">
    <!-- 头部 -->
    <div class="headerBox">
       <div class="header">
      <x-icon type="ios-arrow-left" size="" class="icon-white" @click="goBack"></x-icon>
     检查计划审批
       </div>
    </div>
    <div class="form-section" style="margin-top: 40px;">
      <div class="form-item form-item-style1">
        <div class="label-title">
          <label>检查编号</label>
        </div>
        <div class="input_div">
          <span>{{info.checkNo}}</span>
        </div>
      </div>
      <div class="form-item form-item-style1">
        <div class="label-title">
          <label>被检查单位</label>
        </div>
        <div class="input_div">
          <span>{{info.projectName}}</span>
        </div>
      </div>

      <div class="form-item form-item-style1">
        <div class="label-title">
          <label>检查类型</label>
        </div>
        <div class="input_div">
          <input type="text" v-model="info.checkType"
                 disabled>
          <!-- <span>{{info.checkType}}</span> -->
        </div>
      </div>
      <div class="form-item form-item-style1">
        <div class="label-title">
          <label>检查时间</label>
        </div>
        <div class="input_div" v-if="info.checkDate">
          <span>{{info.checkDate.substring(0,10)}}</span>
        </div>
      </div>
      <div class="form-item form-item-style1">
        <div class="label-title">
          <label>检查组长</label>
        </div>
        <div class="input_div">
          <span>{{info.teamLeader}}</span>
        </div>
      </div>


      <div class="info_div3">
        <p>考核分工</p>
      </div>
      <div class="member_div">
        <ul class="member_list">
          <li v-for="(item,index) in info.divisionList" :key="index">
            <div class="member-item">
              <label>成员1</label>
              <span>{{item.divisionProsonName}}</span>
            </div>
            <div class="member-item">
              <label>分工（考核项）</label>
              <span class="hiddenWord" style="text-align:right;">{{item.standardNameList}}</span>
            </div>
          </li>
        </ul>
      </div>

      <div class="info_div3">
        <p>计划审批</p>
      </div>
      <div class="form-item form-item-style1" style="border-top: 1px solid #ebeef2">
        <div class="label-title">
          <label>审批结果</label>
        </div>
        <div class="input_div">
          <el-radio
            v-model="isApproved"
            label="1"
            :class="iin?'active':''"
            fill="#469b7a"
            @change="getCheck()"
          >同意</el-radio>
          <el-radio
            v-model="isApproved"
            label="0"
            :class="iino?'active':''"
            fill="#469b7a"
            @change="getCheckno()"
          >不同意</el-radio>
        </div>
      </div>
      <div class="form-item form-item-style1" style="border-bottom: none">
        <div class="label-title">
          <label>审批意见</label>
        </div>
      </div>
      <div class="area_div">
        <!-- <textarea placeholder="请输入意见（自行换行）" v-model="info.approveSummary"></textarea> -->
        <x-textarea :max="200" name="description" placeholder="请输入意见(自动换行)" v-model="info.approveSummary" id="tt"></x-textarea>
      </div>
      <div class="form-item form-item-style1">
        <div class="label-title">
          <label class="space1">审批人</label>
        </div>
        <div class="input_div">
          <!-- <input type="text" v-model="info.approvePerson" :disabled="isDisabled" /> -->
          <span>{{info.approvePerson?info.approvePerson:'----'}}</span>
        </div>
      </div>
      <div class="form-item form-item-style1">
        <div class="label-title">
          <label>审批时间</label>
        </div>
        <div class="input_div">
          <span>{{info.operDate}}</span>
        </div>
      </div>

      <div class="btns_div">
        <a class="submitBtn" @click="savedata">提 交</a>
        <a class="cancelBtn" @click="goBack">取 消</a>
      </div>
    </div>
  </div>
</template>
<script>
import formatDate from "../../utils/formatDate";
import {
  XHeader,
  Tabbar,
  TabbarItem,
  Group,
  Cell,
  TransferDom,
  Popup
} from "vux";
import LoadMore from "vux/src/components/load-more/index";
export default {
  data() {
    return {
      isDisabled: true, // 是否禁止输入
      iin: false,
      iino: true,
      isApproved: '1', // 审批意见选择框，以对象结构显示时页面进入时默认不加载
      params: {
        planId: ""
      },
      info: {
        createUser: "",
        createDate: "",
        operUser: "",
        operDate: "",
        deleteUser: "",
        deleteDate: "",
        deleteTag: 0,
        projectId: "",
        projectName: "",
        checkDate: "",
        checkType: "",
        teamLeaderId: "",
        teamLeader: "",
        checkNo: "",
        isSubmitted: 0,
        isApproved: '1',
        approveSummary: "",
        category: "",
        checkArea: "",
        checkContent: "",
        checkPoint: "",
        checkDeptId: "",
        checkDept: "",
        isComplete: 0,
        companyId: "",
        approvePersonId: "",
        approvePerson: "",
        total: 0,
        registerUser: "",
        checkName: "",
        isPlan: 0,
        parentName: "",
        projectDuty: "",
        categorySort: 0,
        equipmentId: "",
        status: 0,
        remarks: "",
        divisionList: [],
        allowApproval: true,
        hiddenCount: 0,
        id: ""
      }
    };
  },
  components: { XHeader, Tabbar, TabbarItem, Group, Cell, TransferDom, Popup },
  created() {
    this.getInfo();
    this.info.operDate = this.getdatanew();
    
     if (this.isApproved == '1') {
       this.iin = true;
       this.iino = false;
     } else {
       this.iin = false;
       this.iino = true;
     }
  },
  methods: {
    getInfo() {
      this.params.planId = this.$route.query.id; //id
      this.$axiosAjax
        .getcheckPlanAssess(this.params)
        .then(res => {
          if (res.data.success == true) {
            this.info = res.data.result;
            this.info.divisionList = res.data.result.divisionList;
            this.info.operDate = formatDate()
          }
        })
        .catch(err => {});
    },
    goBack() {
      this.$router.go(-1);
    },
    getCheck() {
      this.iin = true;
      this.iino = false;
    },
    getCheckno() {
      this.iin = false;
      this.iino = true;
    },
    getdatanew() {
      var date = new Date();
      var seperator1 = "-";
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      var strDate = date.getDate();
      if (month >= 1 && month <= 9) {
        month = "0" + month;
      }
      if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
      }
      var currentdate = year + seperator1 + month + seperator1 + strDate;
    },
    //approversubmit
    savedata() {
      if(!this.iin && !this.iino) {
        this.$vux.alert.show({
            content: '请选择审批状态',
            dialogTransition: ''
          });
        return false;
      }
      if (this.isApproved == '0') {
          if (!this.info.approveSummary) {
            this.$vux.alert.show({
              content: '请输入审批意见',
              dialogTransition: ''
            });
            return false;
          }
      }

      let _this = this;
      this.info.isApproved = this.isApproved;
      this.info.operDate = this.info.operDate + ' 00:00:00';
      this.$axiosAjax
        .savecheckPlanAssess(this.info)
        .then(res => {
          if (res.data.success == true) {
            this.$vux.alert.show({
              content: '提交成功',
              dialogTransition: '',
              onHide () {
                // 关闭时返回上一页面
                _this.$router.go(-1);
              }
            });
          }
        })
        .catch(err => {});
    }
  }
};
</script>
<style lang="less" scoped>
.area_div {
  border-bottom: 1px solid #ebeef2;
  margin-left: 20px;
  padding-right: 20px;
  padding-bottom: 10px;
  textarea {
    border: none;
    resize: none;
    width: 100%;
    font-size: 14px;
    outline: none;
    height: 50px;
  }
}
.space1 {
  letter-spacing: 7px;
}
.form-item {
  .input_div {
    > span.radio_span {
      font-size: 14px;
      color: #666;
      background-image: url("/static/images/radio_not.png");
      background-position: left center;
      background-repeat: no-repeat;
      background-size: 17px 17px;
      padding: 2px 0 2px 20px;
      margin-left: 30px;
    }
    .radio_span.active {
      background-image: url("/static/images/radio_yes.png");
    }
    > span:first-child {
      margin-left: 0;
    }
    .vux-x-icon {
      fill: #999;
      float: right;
      margin-top: 17px;
    }
  }
  #tt {
    background-color: #fff;
    .weui-cell__bd {
      width: 100%;
      display: flex;
      flex-direction: column;
    }
  }
  .weui-cells {
    .vux-x-textarea {
      width: 100%;
    }
  }
}
.info_div3 {
  height: 55px;
  line-height: 45px;
  padding: 0 20px;
  border-top: 10px solid #ebeef2;
  p {
    float: left;
    color: #469b7a;
    font-size: 16px;
    font-weight: bold;
  }
}
.member_div {
  .member_list {
    padding-left: 20px;
    li {
      border-top: 1px solid #ebeef2;
      height: 84px;
      line-height: 30px;
      padding-top: 11px;
      .member-item {
        display: flex;
        justify-content: space-between;
        font-size: 14px;
        padding-right: 20px;
        > label {
          font-weight: bold;
        }
      }
    }
    .member1 {
      color: #ff0000;
    }
    .member2 {
      color: #15bd84;
    }
  }
}
.btns_div {
  background: #ebeef2;
  padding: 30px 20px 55px;
  justify-content: space-between;
  display: flex;
  a {
    height: 40px;
    border-radius: 20px;
    display: inline-block;
    width: 140px;
    text-align: center;
    line-height: 40px;
    color: #fff;
  }
  .submitBtn {
    background: #469b7a;
  }
  .cancelBtn {
    background: #ffb400;
  }
}
.addPlan_select {
  position: fixed;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  top: 0;
  left: 0;
  z-index: 10;
  .planSel_list {
    width: 60%;
    margin: 0 auto;
    padding-top: 150px;
    li {
      border-radius: 10px;
      height: 57px;
      line-height: 57px;
      text-align: center;
      background: #fff;
      margin-bottom: 6px;
      color: #469b7a;
      font-size: 16px;
    }
  }
}
</style>
<style lang="less">
.check_style {
.el-radio__input.is-checked .el-radio__inner {
  border-color: #469b7a;
  background: #469b7a;
}
.el-radio__input.is-checked+.el-radio__label {
  color:  #469b7a;
}
  #tt {
    background-color: #fff;
    padding-left: 0;
    padding-right: 0;
    .weui-cell__bd {
      width: 100%;
      display: flex;
      flex-direction: column;
    }
    .weui-textarea {
      height: 100px !important;
    }
    textarea {
      padding-top: 3px;
    }
  }
}
</style>
